package com.lb.bs.client.processor.handle.dynamics.update;

import com.lb.bs.client.annotation.SingletonMark;
import com.lb.bs.client.beans.LBGrayItemBean;
import com.lb.bs.client.processor.ProcessorHandleService;
import com.lb.bs.client.processor.beans.ProcessorDynamicBean;
import com.lb.bs.client.processor.beans.ProcessorDynamicHandlerBean;
import com.lb.bs.client.repository.StoreCenter;
import com.lb.bs.client.util.CollectionUtils;
import org.reflections.Store;

import java.util.Map;

/**
 * program: LB-BS-Client
 * author: bsworld.xie
 * create: 2019-12-19 17:29
 * description:
 */
@SingletonMark
public class GrayUpdateItemKeyProcessorHandle implements ProcessorHandleService<ProcessorDynamicHandlerBean>  {

    @Override
    public void handleProcess(ProcessorDynamicHandlerBean handlerBean) {
        String key = handlerBean.getKey();
        Map<String, LBGrayItemBean> grayItemKeyMap = StoreCenter.getInstance().getGrayItemKeyMap();
        if (CollectionUtils.isEmpty(grayItemKeyMap)) {
            return;
        }
        LBGrayItemBean grayItemBean = grayItemKeyMap.get(key);
        if (grayItemBean == null) {
            return;
        }
        grayItemBean.setGrayValue(handlerBean.getData());
    }
}
